package com.lo.controller;

import com.lo.common.JsonResult;
import com.lo.service.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("Recommend")
public class RecommendController {
    @Autowired
    private RecommendService recommendService;

    private int LIKE=1;
    @RequestMapping("selectRecommendation")
    public JsonResult selectRecommendation(@RequestParam("userId") Long userId){
        System.out.println("推荐测试id:"+userId);
        return recommendService.selectRecommendation(userId);
    }

    //删：删除用户对某一商品的所有记录
    @RequestMapping("deleteUserAllRateById")
    public  JsonResult deleteUserAllRateById(@RequestParam("userId")Long userId,
                                             @RequestParam("courseId")Long courseId){
        return recommendService.deleteUserAllRateById(userId,courseId);
    }

    @RequestMapping("LikeCourse")
    public JsonResult LikeCourse(@RequestParam(value = "userId")Long userId,
                                 @RequestParam(value = "courseId")Long courseId){
        System.out.println(userId+" "+courseId);
        return recommendService.update(userId,courseId,LIKE);
    }
    @RequestMapping("UnLikeCourse")
    public JsonResult UnLikeCourse(@RequestParam(value = "userId")Long userId,
                                 @RequestParam(value = "courseId")Long courseId){
        System.out.println(userId+" "+courseId);
        return recommendService.update(userId,courseId,LIKE);
    }

    @RequestMapping("getLike")
    public JsonResult getLike(@RequestParam(value = "userId")Long userId,
                                   @RequestParam(value = "courseId")Long courseId){
//        System.out.println(userId+" "+courseId);
        return recommendService.getLike(userId,courseId);
    }
}
